<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Mykpi extends CI_Controller {

	function Mykpi()
	{
		parent::__construct();
		$this->load->library('session');
		$this->load->library('form_validation');
		$this->load->library('encrypt');
                $this->load->model('mkpi');
		$this->load->model('mmaster');
                $this->load->model('musers');
		$this->load->model('mglobal');
		$this->is_logged_in();
		#$this->mjadwal->saveLog();
	}
        
	function is_logged_in()
	{
		$is_logged_in = $this->session->userdata('is_logged_in');
		if(!isset($is_logged_in) || $is_logged_in != true)
		{
			redirect(base_url() .'index.php/login');
		}		
	}
	
        function index($id="")
	{
		$data['template'] = "shell/smooth-side";
                $data['users']    = $this->musers->getUser();
                
                if($id == "") $id = $this->session->userdata('username');
                $data['judul']          = $this->mkpi->getJudul($id);
                $data['id']	        = $id;
                $data['getKPI']         = $this->mkpi->getKPI($id);
		
                $posisi = $this->mkpi->getPosisi($id);
                if($posisi == "Agent" || $posisi =="Outlet"){
                        $data['main_view']      = 'f-mykpi';
                }elseif($posisi == "Cluster"){
                        $data['main_view']      = 'f-mykpi-cluster';
                }elseif($posisi == "Regional"){
                        $data['main_view']      = 'f-mykpi-regional';
                }
                
		$this->load->view($data['template'],$data);
	}
        
        
        
}